from django.db import models
import uuid


# Create your models here.
class Article(models.Model):
    uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    title = models.CharField(max_length=255)
    author = models.TextField()
    journal = models.CharField(max_length=255)
    img_src = models.CharField(max_length=255)
    pdf_src = models.CharField(max_length=255)
    tags = models.JSONField(blank=True)
    pub_year = models.IntegerField()
    pub_month = models.IntegerField(default=0)
    is_main_author = models.BooleanField(default=True)
    web_url = models.CharField(max_length=255, default='')
    page_info = models.CharField(max_length=255, default='', blank=True)
    index = models.IntegerField(default=0)
    def __str__(self):
        return self.title


class Software(models.Model):
    uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    name = models.CharField(max_length=255)
    src = models.CharField(max_length=255)
    url = models.CharField(max_length=255)
    description = models.TextField(blank=True)

    def __str__(self):
        return self.name

class Member(models.Model):
    uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    name = models.CharField(max_length=255)
    img = models.CharField(max_length=255, blank=True)
    identity = models.CharField(max_length=255, blank=True)
    email = models.EmailField(blank=True)
    address = models.CharField(max_length=255, blank=True)
    description = models.CharField(max_length=255, blank=True)

    def __str__(self):
        return self.name


class EducationUrl(models.Model):
    uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    category = models.CharField(max_length=255)
    url = models.CharField(max_length=255)
    title = models.CharField(max_length=255)
    img_url = models.CharField(max_length=255, blank=True)

    def __str__(self):
        return self.title


class News(models.Model):
    uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    title = models.CharField(max_length=255)
    content = models.TextField()
    year = models.IntegerField()
    month = models.CharField(max_length=64)
    url = models.CharField(max_length=255, blank=True)

    def __str__(self):
        return self.uuid
